package com.shop.cereshop.business.service.write.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.shop.cereshop.business.dao.write.CereWriteOffRecordDAO;
import com.shop.cereshop.business.service.write.CereWriteOffRecordService;
import com.shop.cereshop.commons.domain.write.CereWriteOffRecord;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lx
 */
@Slf4j
@Service
public class CereWriteOffRecordServiceImpl extends ServiceImpl<CereWriteOffRecordDAO, CereWriteOffRecord> implements CereWriteOffRecordService {

    private final CereWriteOffRecordDAO cereWriteOffRecordDAO;

    public CereWriteOffRecordServiceImpl(CereWriteOffRecordDAO cereWriteOffRecordDAO) {
        this.cereWriteOffRecordDAO = cereWriteOffRecordDAO;
    }

    @Override
    public CereWriteOffRecord getWriteOffRecordDetail(Long recordId) {
        //根据recordId查询核销记录
        return lambdaQuery().eq(CereWriteOffRecord::getRecordId, recordId).one();
    }

    @Override
    public List<CereWriteOffRecord> getWriteOffRecordList(Long shopId, Integer page, Integer pageSize) {
        //根据shopId分页查询核销记录
        PageHelper.startPage(page, pageSize);
        return cereWriteOffRecordDAO.getWriteOffRecordList(shopId);
    }
}